package com.example.administrator.dagger2demo.application;

import android.app.Application;
import android.content.Context;

import com.example.administrator.dagger2demo.di.ApiModule;
import com.example.administrator.dagger2demo.di.AppComponent;
import com.example.administrator.dagger2demo.di.DaggerAppComponent;
import com.example.administrator.dagger2demo.di.MainModule;

/**
 * Created by Administrator on 2016/4/12.
 */
public class DemoApplication extends Application {
    DemoApplication instance;
    AppComponent appComponent;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        appComponent = DaggerAppComponent
                .builder()
                .apiModule(new ApiModule())
                .mainModule(new MainModule(this))
                .build();
    }

    public static DemoApplication get(Context context) {
        return (DemoApplication) context.getApplicationContext();
    }

    public AppComponent getAppComponent() {
        return appComponent;
    }


}
